package com.hq.fxh.No5_User.User.Activity;

import android.support.design.widget.TabLayout;
import android.support.v4.app.Fragment;
import android.support.v4.view.ViewPager;
import android.view.View;
import android.widget.LinearLayout;

import com.hq.fxh.No0_ChengQu.Activity.BaseActivity;
import com.hq.fxh.No5_User.User.Adapter.PAdapter_MyGZ;
import com.hq.fxh.No5_User.User.Fragment.Fragment_GuanZhu_People;
import com.hq.fxh.No5_User.User.Fragment.Fragment_GuanZhu_Plate;
import com.hq.fxh.R;

import java.util.ArrayList;

public class MyGuanZhu extends BaseActivity implements View.OnClickListener {

    protected TabLayout tabMyGuanZhu;
    protected ViewPager viewPagerMyGuanZhu;
    protected LinearLayout layoutGZBack;
    private Fragment_GuanZhu_People fragment_People;
    private Fragment_GuanZhu_Plate fragment_Plate;


    @Override
    protected int getLayoutId() {
        return R.layout.activity_my_guan_zhu;
    }

    @Override
    protected void initView() {
        tabMyGuanZhu = (TabLayout) findViewById(R.id.tab_MyGuanZhu);
        viewPagerMyGuanZhu = (ViewPager) findViewById(R.id.viewPager_MyGuanZhu);
        layoutGZBack = (LinearLayout) findViewById(R.id.layout_GZ_back);
        layoutGZBack.setOnClickListener(MyGuanZhu.this);
    }

    @Override
    protected void initData() {
        PAdapter_MyGZ adapter = new PAdapter_MyGZ(getSupportFragmentManager());
        ArrayList<Fragment> datas = new ArrayList<>();
        fragment_People = new Fragment_GuanZhu_People();
        datas.add(fragment_People);
        fragment_Plate = new Fragment_GuanZhu_Plate();
        datas.add(fragment_Plate);
        adapter.setDatas(datas);
        viewPagerMyGuanZhu.setAdapter(adapter);
        viewPagerMyGuanZhu.addOnPageChangeListener(new TabLayout.TabLayoutOnPageChangeListener(tabMyGuanZhu));
        tabMyGuanZhu.addOnTabSelectedListener(new TabLayout.ViewPagerOnTabSelectedListener(viewPagerMyGuanZhu));


    }

    @Override
    public void onClick(View view) {
        if (view.getId() == R.id.layout_GZ_back) {
          finish();
        }
    }
}
